<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <link rel="stylesheet" href="<%=basePath%>static/plugins/jsgrid/css/jsgrid.min.css">
    <link rel="stylesheet" href="<%=basePath%>static/plugins/jsgrid/css/jsgrid-theme.min.css">
    <link rel="stylesheet" href="<%=basePath%>static/plugins/jsgrid/css/demo.css">
</head>
<body>

<div id="jsGrid"></div>


<script src="<%=basePath%>static/plugins/jquery-2.2.4.min.js"></script>
<script src="<%=basePath%>static/plugins/jsgrid/js/jsgrid.min.js"></script>
<script src="<%=basePath%>static/plugins/jsgrid/js/i18n/zh-cn.js"></script>
<script>
    $(function() {
        jsGrid.locale("zh-cn");

        $("#jsGrid").jsGrid({
            height: "70%",
            width: "100%",
            paging:true,
            sorting: true,
            pageLoading:true,
            pageSize:2,
            editing :true,
            autoload: true,

            deleteConfirm: "你确定要删除吗?",
            controller: {
                loadData: function(filter) {

                    return  $.ajax({
                        url: "<%=basePath%>admin/role/list",
                        type:'POST',
                        data:filter,
                        dataType: "json"
                    });

                },
                updateItem:function (item) {
                    $.ajax({
                        url: "<%=basePath%>admin/role/update",
                        type:'POST',
                        data:item,
                        dataType: "json",
                        success:function (data) {
                            if(data.code=="10000")
                            {
                                alert('success');
                            }
                            else{
                                alert(data.msg);
                            }
                        },
                        error:function () {
                            alert("网络异常");
                        }
                    });
                    return item;
                }
            },
            fields: [
                { name: "id", title:'编号', width: 50 },
                { name: "rolename",title:'角色名称',type:'text', width: 100 },
                { name: "description", title:'描述',type:'text', width: 200 },
                { name: "state",  title:'状态',type:'text', width:50},
                { type: "control" }
            ],
            onItemEditing:function (args) {
              // alert(args.item.id);
                //alert("xx") 开始编辑的时候
            }
        });

    });
</script>
</body>
</html>
